$(function(){
	//初始化
	initData();
	
	function initData () {
		var pid= sessionStorage.getItem("diagnosisrecordNum"); 
		console.log(pid);
		var param = {"pid":pid};
		diagnosisRecordModule.diagnosisDetailsModule(param,function(callBack){ 
			console.log(callBack.prescription);
			var result = callBack.prescription;
			if(result){
				var showhtml="";
				showhtml+="<div class=\"font3 description-disease\">";
				showhtml+="<span>病情描述：</span>";
				showhtml+="<p id=\"description\">"+result.questionbody+"</p>";
				showhtml+="</div>";
				var $diagnosis = result.diagnosis;
				 if($diagnosis) {
				   showhtml+="<p class=\"diagnosisresult font3\">诊断结果：<span>"+$diagnosis+"</span></p>";
			    }else{
			   	   showhtml+="<p class=\"diagnosisresult font3\">诊断结果：<span style=\"color:#999\">无</span></p>";
			    }
				
				showhtml+="<p class=\"diagnosistime font3\">诊断日期：<span>"+result.createtime+"</span></p>";
		
				var $told = result.told;
			    if($told) {
				   showhtml+="<p class=\"diagnosisrecord font3\">医　　嘱：<span>"+$told+"</span></p>";
			    }else{
			   	   showhtml+="<p class=\"diagnosisrecord font3\">医　　嘱：<span style=\"color:#999\";>无</span></p>";
			    }
				showhtml+="<div class=\"diagnosismedicine font3\">";
				showhtml+="<span class=\"font3\">用药信息：</span>";
				showhtml+="<table>";
				showhtml+="<tbody>";
				console.log(result.infolist);
				if(result.infolist){
					for(var key in result.infolist) {
						var infor = result.infolist[key];
						showhtml+="<tr class=\"medicinetext\">";
						showhtml+="<td id=\"medicine-name\">"+infor.name+"</td>";
						showhtml+="<td class=\"td-right\">×<b id=\"medicineNum\" style=\"font-weight:normal;\">"+infor.count+"</b></td></tr>";
						showhtml+="<tr class=\"medicinetnum\">";
						console.log(infor.usageMethod);
						
						if(infor.usageMethod!=""){
							var strs = infor.usageMethod.split("-"); //字符分割
							showhtml+='<td id=\"medicineDosage\">'+strs[1]+'</td>';
							showhtml+='<td class=\"td-right\" id=\"medicineDirection\">'+strs[0]+'</td>';
						}
						showhtml+="</tr>"	
					}
				}else{
					showhtml+="<td style=\"color:#999\";>无</td>";
				}
				showhtml+="</tbody>";
				showhtml+="</table>"
				showhtml+="</div>";
			}
			$(".diseasedetails").append(showhtml);
		})	
	}
	$(".html-loding").hide();
});

			
				
					
						
						
				
						
						
					
				
			